package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.Building;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.BuildingService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:BuildingController
 * @Date:2025/9/18 11:29
 */
@RestController
@RequestMapping("/building")
public class BuildingController {
    @Resource
    private BuildingService buildingService;

    @PostMapping
    public JsonResult saveBuilding(Building building) {
        return buildingService.saveBuilding(building);
    }

    @GetMapping("/{id}")
    JsonResult findOneById(@PathVariable("id")String id) {
        return buildingService.findBuildingById(id);
    }

    @GetMapping
    JsonResult findAll(){
        return buildingService.findBuildingsAll();
    }

    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id")String id) {
        return buildingService.deleteBuilding(id);
    }

    @PutMapping
    JsonResult updateOne(@RequestBody Building building) {
        return buildingService.updateBuilding(building);
    }
}
